function loadboard()
{
  var ajaxRequest;
  try {
    ajaxRequest = new XMLHttpRequest();
  }catch(e) {
    alert("Exception");
    console.log(e);
  }

  document.getElementById("answers").value = "";
  document.getElementById("response").innerHTML = "";
  //document.getElementById("heading").innerHTML = "LOADING>>>";

  ajaxRequest.onreadystatechange = function() {
    console.log(ajaxRequest);
    if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
      var string = ajaxRequest.responseText;
      var chararray = string.split("");
      var char;
      var index = 1;
      for(char in chararray) {
        var id = "loc" + index;
        document.getElementById(id).innerHTML = chararray[index - 1];
        index = index + 1;
      }

      start_timer(30);
    }
  }

  ajaxRequest.open("GET", "/boggle/loadboard/", true);
  ajaxRequest.send(null);
}

function checkanswers(form)
{
  var answers = document.getElementById("answers").value;
  console.log(answers);
  $.post("boggle/checkanswers/", {"answers": answers}, 
      function(data) {
        console.log(data);
        var display = "<h1>Answer Evaluation: </h1>";
        var score=0;
        jQuery.each(data.words, function(index, value) {
          if(data.answer[index] == 1) {
            display += ((1 +index) + " " + value + " " + "success " + data.score[index] );
            } else if (data.answer[index] == 0){
              display += ((index + 1) + " " + value + " " + "no word link " + data.score[index] );
            } else if (data.answer[index] == 2){
              display += ((1 + index) + " " + value + " " + "no such word " + data.score[index] );
            } else if (data.answer[index] == 3){
              display += ((index + 1) + " " + value + " " + "total bs " + data.score[index] );
            }
            display += "<br/>";
            score += data.score[index];
          }); 
        display += "<h1>TOTAL SCORE: " + score + "</h1>";
        document.getElementById("response").innerHTML = display;
      });
}
